#include "RSIM_INC.h"
#include "Svd.h"

#include <iostream>

using namespace std;
using namespace RSIM;


int main(){
        double a[]={    0.585264091152724,      0.757200229110721,      0.075854289563064,      0.934010684229183,      0.011902069501241,      0.311215042044805,      0.262971284540144,
                        0.549723608291140,      0.753729094278495,      0.053950118666607,      0.129906208473730,      0.337122644398882,      0.528533135506213,      0.654079098476782,
                        0.285839018820374,      0.567821640725221,      0.779167230102011,      0.469390641058206,      0.794284540683907,      0.601981941401637,      0.748151592823709,
                        0.285839018820374,      0.567821640725221,      0.779167230102011,      0.469390641058206,      0.794284540683907,      0.601981941401637,      0.748151592823709
        };
        
        Matrix A1(4,7,a);
        
        // A is a 7 x 4 matrix
        Matrix A = ~A1;

        // Calculate SVD of matrix A.
        SVD svd(A);
        Matrix M;
        svd.getColumnBasis(M);
        cout<<M<<endl<<endl;
        Matrix U,S,V;
        
        
        svd.getU(U);
        svd.getS(S);
        svd.getV(V);
        
        cout<<U<<endl<<endl;
        cout<<S<<endl<<endl;
        cout<<V<<endl<<endl;
        
        // A = U*S*V' and the following expression should be zero.
        cout<< A - U*S*(~V)<<endl<<endl;
        
return 0;
}